<template>
  <div>
    <Son></Son>
  </div>
</template>

<script lang="ts">
import { defineComponent, provide, reactive } from 'vue'
import Son from "./Son.vue"

interface Member {
  id: number,
  name: string
}


export default defineComponent({
  components: {
    Son
  },
  setup() {
    const msg: string = 'hello world!'

    provide('msg', msg)


    // provide一个reactive
    const userInfo: Member = reactive({
      id: 1,
      name: 'Petter'
    })

    provide('userInfo', userInfo)


    const tags: string[] = ['中餐', '西餐', '粤菜']
    provide('tagsCount', tags.length)
    provide('tagsCount1', () => {
      return tags.length
    })

    let name: string = 'Petter!';
    // provide('name', name)//不会变
    provide('name', (): string => {
      return name
    })

    provide('tags', tags)


    setTimeout(() => {
      userInfo.name = 'cocoMemlon!'
      name = "kaylu"

      tags.push('海鲜')
    }, 2000)



    return {}
  }
})
</script>

<style scoped>

</style>
